package theOrbalEra.client.OrbalArts.render;

import org.lwjgl.opengl.GL11;

import theOrbalEra.common.util.DefultValue;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;

public class OrbalRenderNapalmBreath extends OrbalRenderOrbalArt {
	private int pho=0;
    private Entity entity;
	@Override
	public void doRender(Entity entity, double d0, double d1, double d2,
			float f, float f1) {
		this.renderNapalmBreath(entity,d0,d1,d2,f,f1);
		this.entity=entity;

	}

	private void renderNapalmBreath(Entity entity, double d0,
			double d1, double d2, float f, float f1) {
		
		GL11.glDisable(GL11.GL_CULL_FACE);
         GL11.glDisable(GL11.GL_LIGHTING);
		    this.loadTexture(DefultValue.Texture_NapalmBreath1);
		     GL11.glPushMatrix();
		     GL11.glTranslatef((float)d0, (float)d1, (float)d2);
		     this.renderAABBwithUV(AxisAlignedBB.getBoundingBox(-0.5D, -0.5D, -0.5D, 0.5D, 2.0D, 0.5D));
		     GL11.glPopMatrix();

	}



	private void renderAABBwithUV(AxisAlignedBB boundingBox) {
		Tessellator tessellator=new Tessellator();
		tessellator.startDrawingQuads();
		
		this.tick++;
		if(tick==0){
			pho++;
		}
		if(tick==30){
			pho++;
		}
		if(tick==60){
			pho++;
			
		}
		if(tick==90){
			pho++;
			
		}
		if(tick==120){
			pho++;
			
		}
		if(tick==150){
			pho++;
			
		}
		if(tick==180){
			pho++;
			
		}

		if(tick==210){
			pho++;
			
		}
		if(tick==240){
			tick=0;
			this.entity.setDead();
		}

		double Dwidth=0.125D*pho;
		double Uhight=1.0D;
		double Uwidth=0.125D+0.125D*pho;
		double Dhight=0.0D;
	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ, Dwidth, Dhight);
	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.maxY, boundingBox.minZ, Uwidth,Dhight);
	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.minY, boundingBox.minZ, Uwidth, Uhight);
	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.minY, boundingBox.minZ, Dwidth, Uhight);

	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ, Dwidth, Dhight);
	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ, Dwidth, Uhight);
	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.minY, boundingBox.maxZ, Uwidth, Uhight);
	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ, Uwidth, Dhight);

	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.minY, boundingBox.minZ, Uwidth, Uhight);
	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.minY, boundingBox.maxZ, Dwidth, Uhight);
	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ, Dwidth, Dhight);
	    tessellator.addVertexWithUV(boundingBox.minX, boundingBox.maxY, boundingBox.minZ, Uwidth, Dhight);
	    
	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.minY, boundingBox.minZ, Uwidth, Uhight);
	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ, Dwidth, Uhight);
	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ, Dwidth, Dhight);
	    tessellator.addVertexWithUV(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ, Uwidth, Dhight);
		
	    tessellator.draw();
		
	}

}
